package com.atgugui.eduservice.controller;


import com.atgugui.commonutils.Result;
import com.atgugui.eduservice.entity.subject.OneSubject;
import com.atgugui.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-08-26
 */
@Api(tags = "课程分类模块")
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    @ApiOperation(value = "添加课程分类")
    @PostMapping("/addSubject")
    public Result addSubject(MultipartFile file) {
        eduSubjectService.addSubject(file,eduSubjectService); // 上传过来的excel文件
        return Result.ok();
    }

    @ApiOperation(value = "获取所有的课程分类")
    @GetMapping("/getAllSubject")
    public Result getAllSubject() {
        List<OneSubject> oneSubjects = eduSubjectService.getAllOneSubject();
        return Result.ok().data("subjects",oneSubjects);
    }
}

